<?php

//TODO Renommer les id et class des champs pour le css pour avoir quelques chose de plus propre
function formFlatAdmin($action, $immeubles){
  Doo::loadHelper('DooForm');
  $imm['none'] = '';
  foreach ($immeubles as $k){
    $imm[$k->imm_id] = $k->imm_nom;
  }
  $form = new DooForm(array(
         'method' => 'post',
         'action' => $action,
       'attributes' => array('onSubmit'=>'return submitFlat();','id' => 'componen-add-flat-screen-box-form'),
         'elements' => array(
         'name' => array('text', array(
             'required' => true,
             'label' => "Nom : <span class='red-required'>*</span>",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'componen-add-flat-screen-box-form-name', 'class' => 'personnal-border required', 'type_validate' => 'str_max45'),
             'validators' => array(
                 array('required','Field required'),
                 array('maxlength',45,'This is too long')
             )
        )),
        'loyer' => array('text', array(
             'required' => true,
             'label' => "loyer en € : <span class='red-required'>*</span>",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'componen-add-flat-screen-box-form-loyer','class' => 'personnal-border required'),
             'validators' => array(
                 array('required','Field required')
             )
        )),
        'surface' => array('text', array(
             'required' => true,
             'label' => "surface en m²: <span class='red-required'>*</span>",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'componen-add-flat-screen-box-form-surface', 'class' => 'personnal-border required'),
             'validators' => array(
                 array('required','Field required')
             )
        )),
        'immeuble' => array('select', array(
             'required' => true,
             'label' => "immeuble : <span class='red-required'>*</span>",
           'multioptions' => $imm,
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'componen-add-flat-screen-box-form-immeuble', 'class' => 'personnal-border required'),
             'validators' => array(
                 array('required','Field required')
             )
        )),
        'detail' => array('textarea', array(
             'required' => true,
             'label' => "detail: <span class='red-required'>*</span>",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'componen-add-flat-screen-box-form-detail', 'class' => 'personnal-border required'),
             'validators' => array(
                 array('required','Field required')
             )
        )),
        'action-indicator' => array('hidden', array(
             'required' => true,
         'attributes' => array('id'=>'action-indicator'),
             'validators' => array(
                 array('required','Field required')
             )
        )),
        'id' => array('hidden', array(
             'required' => true,
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'componen-add-flat-screen-box-form-id'),
             'validators' => array(
                 array('required','Field required')
             )
        )),
        'submit' => array('submit', array(
            'label' => "Valider",
          'attributes' => array('id' => 'contact-submit', 'class'=>'personal-button'),
            'field-wrapper' => 'div'
        ))
     ),
    ));
    return $form;
}

//Gestion de la réservation des chambres
function formReservationAdmin($action){
  Doo::loadHelper('DooForm');
  $form = new DooForm(array(
         'method' => 'post',
         'action' => $action,
       'attributes' => array('onSubmit'=>'return submitReserv();','id' => 'component-change-reservation-form'),
         'elements' => array(
         'id' => array('hidden', array(
             'required' => true,
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-chambre', 'class' => 'personnal-border required'),
             'validators' => array(
                 array('required','Field required')
             )
        )),'chambreres' => array('hidden', array(
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-chambreres', 'class' => 'personnal-border required')
        )),
        'reservation_indicator' => array('hidden', array(
             'required' => true,
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-indicator', 'class' => 'personnal-border required'),
             'validators' => array(
                 array('required','Field required')
             )
        )),
         'locataire' => array('text', array(
             'required' => true,
             'label' => "Nom : <span class='red-required'>*</span>",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-locataire', 'class' => 'personnal-border required'),
             'validators' => array(
                 array('required','Field required')
             )
        )),
         'prenom' => array('text', array(
             'label' => "Prénom : ",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-prenom', 'class' => 'personnal-border')
        )),
        'daten' => array('text', array(
             'label' => "Date de naissance : ",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-daten', 'class' => 'personnal-border type-date')
        )),
        'lieun' => array('text', array(
             'label' => "Lieu de naissance : ",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-lieun', 'class' => 'personnal-border')
        )),
        'datedeb' => array('text', array(
             'required' => true,
             'label' => "Date d'entrée : <span class='red-required'>*</span>",
         'field-wrapper' => 'div',
         'attributes' => array('AUTOCOMPLETE'=>'OFF','id'=>'component-change-reservation-form-datedeb','class' => 'personnal-border required calendar type-date'),
             'validators' => array(
                 array('required','Field required')
             )
        )),
        'datefin' => array('text', array(
             'label' => "Date de de départ : ",
         'field-wrapper' => 'div',
         'attributes' => array('AUTOCOMPLETE'=>'OFF','id'=>'component-change-reservation-form-datefin', 'class' => 'personnal-border required calendar type-date')
        )),
        'date_entree' => array('text', array(
             'label' => "",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-date_entree', 'class' => 'personnal-border', "style" => "display: none;")
        )),        
        'adresse' => array('text', array(
             'label' => "Adresse : ",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-adresse', 'class' => 'personnal-border')
        )),
        'ville' => array('text', array(
             'label' => "Code postal : ",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-ville', 'class' => 'personnal-border')
        )),
        'dept' => array('text', array(
             'label' => "Ville : ",
         'field-wrapper' => 'div',
         'attributes' => array('id'=>'component-change-reservation-form-dept', 'class' => 'personnal-border')
        )),
        'submit' => array('submit', array(
            'label' => "Valider",
          'attributes' => array('id' => 'reservation-submit', 'class'=>'personal-button'),
            'field-wrapper' => 'div'
        ))
     ),
    ));
    return $form;
}


?>